<?php

require_once('../function/connection.php');


session_start();

connection();

if (isset($_SESSION['zalogowany'])) {
    $_SESSION['jgrowl'] = "Witam, " . $_SESSION['use_email'];
    header('Location: ../view/user_panel.php');
} else {

    if (isset($_POST['wyslij'])) {

        if (mysql_num_rows(mysql_query("SELECT use_email 
   FROM user WHERE use_email = '" . $_POST['use_email']. "'")) > 0) {


            if (mysql_num_rows(mysql_query("SELECT use_1_id FROM user
       WHERE use_email = '" . $_POST['use_email'] . "' 
       && use_password = '" . $_POST['use_password'] . "' ")) > 0) {

                $_SESSION['zalogowany'] = true;
                $_SESSION['use_email'] = $_POST['use_email'];
                $_SESSION['use_password'] = $_POST['use_password'];
                $_SESSION['jgrowl'] = "Zostałeś zalogowany.";

                header('Location: ../view/edit_user_view.php');
            } else {
                $_SESSION['jgrowl'] = "Złe hasło, proszę spróbować ponownie";
                header('Location: /');
            }
        } else {
            $_SESSION['jgrowl'] = "Nie ma takiego użytkownika";
            header('Location: /');
        }
    }
}
?>

